function Emulator() {
	this.id = null;
	this.isFullScreen = false;
	this.width = null;
	this.height = null;
	this.regulatedSize = {
		width : null,
		height : null
	};
	this.isRotated = false;
	this.isOpened = false;
};
// ////////static variable////////////////
Emulator.screenWidth = SysCfg.emulatorMaxWidth;
Emulator.screenHeight = SysCfg.emulatorMaxHeight;
Emulator.regulatedSize = {
	width : 310,
	height : 518
};
Emulator.predefineWidth;
Emulator.predefineHeight;
Emulator.calReverseFlag = false;
// ////////static methods////////////////
/**
 * regulate the size of emulator
 * 
 * @param {int}
 *            width：specified width
 * @param {int}
 *            height:specified height
 * @return {float} scaling
 */
Emulator.regulateScreenSize = function(emulatorScreen, width, height) {
	Emulator.getRegulatedSize(emulatorScreen, width, height);
	var w = emulatorScreen.regulatedSize.width;
	var h = emulatorScreen.regulatedSize.height;
	EmulatorManager.currentEmulator.query('panel')[0].setWidth(w + 'px');
	EmulatorManager.currentEmulator.query('panel')[0].setHeight(h + 'px');
	var a = h * w;
	var b = height * width;
	var scaling = Util.roundTo(a / b * 100, 2);
	return scaling;
};
Emulator.regulateScreenSizeWithNoZoom = function(emulatorScreen, width, height) {
	emulatorScreen.regulatedSize.width = width;
	emulatorScreen.regulatedSize.width = height;
	EmulatorManager.currentEmulator.query('panel')[0].setWidth(width + 'px');
	EmulatorManager.currentEmulator.query('panel')[0].setHeight(height + 'px');
};
/**
 * scall the emulator according to the specified width and height
 * 
 * @param {Object}
 *            width
 * @param {Object}
 *            height
 */
Emulator.getRegulatedSize = function(emulatorScreen, width, height) {
	var w = width;
	var h = height;
	if (Emulator.calReverseFlag) {
		w = height;
		h = width;
		Emulator.calReverseFlag = false;
	}
	if (width > Emulator.screenWidth && height > Emulator.screenHeight) {
		if (width < height) {
			h = Emulator.screenHeight;
			w = h * width / height;
			if (w > Emulator.screenWidth) {
				var flag = true;
				var num = 0.9;
				do {
					h = h * num;
					w = h * width / height;
					if (w <= Emulator.screenWidth) {
						flag = false;
					} else {
						num -= 0.1;
					}
				} while (flag);
			}
		} else if (height < width) {
			w = Emulator.screenWidth;
			h = w * height / width;
			if (h > Emulator.screenHeight) {
				var flag = true;
				var num = 0.9;
				do {
					w = w * num;
					h = w * height / width;
					if (h <= Emulator.screenHeight) {
						flag = false;
					} else {
						num -= 0.1;
					}
				} while (flag);
			}
		} else {
			if (height > Emulator.screenHeight) {
				w = Emulator.screenHeight;
				h = Emulator.screenHeight;
			}
		}
	} else if (width > Emulator.screenWidth) {
		w = Emulator.screenWidth;
		h = w * height / width;
	} else if (height > Emulator.screenHeight) {
		h = Emulator.screenHeight;
		w = h * width / height;
	}
	if (w <= Emulator.screenHeight && h <= Emulator.screenWidth) {
		emulatorScreen.regulatedSize.width = w;
		emulatorScreen.regulatedSize.height = h;
		return emulatorScreen.regulatedSize;
	} else {
		Emulator.calReverseFlag = true;
		return Emulator.getRegulatedSize(emulatorScreen, h, w);
	}
};
/**
 * rotate screen (change the direction of emulator)
 */
Emulator.rotateScreen = function(emulatorScreen, emulatorScreenObj) {
	var w = emulatorScreenObj.width;
	var h = emulatorScreenObj.height;
	emulatorScreenObj.width = h;
	emulatorScreenObj.height = w;
	emulatorScreen.query('panel')[0].setHeight(emulatorScreenObj.height + 'px');
	emulatorScreen.query('panel')[0].setWidth(emulatorScreenObj.width + 'px');
	emulatorScreenObj.isRotated ? false : true;
};
